/*
 * @Author: your name
 * @Date: 2020-04-03 18:10:54
 * @LastEditTime: 2020-04-26 16:50:09
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \v1.0.0\common\framework\utils\navigate.js
 */
import store from '@/store'
//普通页面跳转
const gotoPage = (path) => {
	if (!path) return;
	let navigateFlag = store.getters.navigateFlag;
	if (navigateFlag) {
		return;
	}
	store.commit('setNavigateFlag',true)
	uni.navigateTo({
		url: path
	});
	setTimeout(() => {
		store.commit('setNavigateFlag',false);
	}, 200)
	
};

//页面跳转到tabBar
const gotoTabPage = (path) => {
	if (!path) return;
	let navigateFlag = store.getters.navigateFlag;
	if (navigateFlag) {
		return;
	}
	
	store.commit('setNavigateFlag',true)
	uni.switchTab({
		url: path
	});
	setTimeout(() => {
		store.commit('setNavigateFlag',false)
	}, 200)
};

//页面跳转到tabBar
const redirectPage = (path) => {
	if (!path) return;
	let navigateFlag = store.getters.navigateFlag;
	if (navigateFlag) {
		return;
	}
	
	store.commit('setNavigateFlag',true)
	uni.redirectTo({
		url: path
	});
	setTimeout(() => {
		store.commit('setNavigateFlag',false)
	}, 200)
};



export {
	gotoPage,
	gotoTabPage,
	redirectPage
}
